<template>
  <el-dialog
    :title="'输入数据'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
      <el-form-item label="网关号" prop="gwsn" class="input-container">
        <el-input v-model="dataForm.gwsn" placeholder="网关号" :readonly="true"></el-input>
      </el-form-item>
      <el-form-item label="暂停率" prop="pauseRate">
        <el-select v-model="dataForm.pauseRate" placeholder="请选择暂停率">
          <el-option label="0.6" value="0.6"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="分页大小" prop="pageSize">
        <el-select v-model="dataForm.pageSize" placeholder="请选择分页大小">
          <el-option label="10" value="10"></el-option>
          <el-option label="20" value="20"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="当前页数" prop="pageNum">
        <el-select v-model="dataForm.pageNum" placeholder="请选择当前页数">
          <el-option label="1" value="1"></el-option>
          <el-option label="2" value="2"></el-option>
        </el-select>
      </el-form-item>
<!--      <el-form-item label="分页大小" prop="pageSize">-->
<!--        <el-input v-model="dataForm.pageSize" placeholder="分页大小"></el-input>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="当前页数" prop="pageNum">-->
<!--        <el-input v-model="dataForm.pageNum" placeholder="当前页数"></el-input>-->
<!--      </el-form-item>-->
      <el-form-item label="开始时间" prop="startDate">
        <el-date-picker
          v-model="dataForm.startDate"
          value-format="yyyy-MM-dd"
          type="date"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="结束时间" prop="endDate">
        <el-date-picker
          v-model="dataForm.endDate"
          value-format="yyyy-MM-dd"
          type="date"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <!--      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>-->
      <el-button type="primary" @click="sub()">确定</el-button>
    </span>

    <el-dialog
      width="50%"
      title="数据分析"
      :visible.sync="innerVisible"
      append-to-body>
      <el-table
        :data="analysisList"
        border
        ref="singleTable"
        highlight-current-row
        :header-cell-style="{background:'#17b3a3',color:'#FFFFFF'}"
        style="width: 100%;">
        <el-table-column
          type="selection"
          header-align="center"
          align="center"
          width="50">
        </el-table-column>
        <el-table-column
          prop="gwsn"
          header-align="center"
          align="center"
          label="网关号">
        </el-table-column>
        <el-table-column
          prop="pauseRate"
          header-align="center"
          align="center"
          label="暂停率">
        </el-table-column>
        <el-table-column
          prop="theoNum"
          header-align="center"
          align="center"
          label="理论数据量">
        </el-table-column>
        <el-table-column
          prop="actNum"
          header-align="center"
          align="center"
          label="实采数据量">
        </el-table-column>
        <el-table-column
          prop="avePa"
          header-align="center"
          align="center"
          label="平均电流">
        </el-table-column>
        <el-table-column
          prop="avePv"
          header-align="center"
          align="center"
          label="平均电压">
        </el-table-column>
        <el-table-column
          prop="time"
          header-align="center"
          align="center"
          label="开始时间">
        </el-table-column>
      </el-table>
    </el-dialog>
  </el-dialog>
</template>

<script>
  export default {
    name:'analysis',
    data () {
      return {
        analysisList:[],
        outerVisible: false,
        innerVisible: false,
        visible: false,
        dataForm: {
          gwsn: '',
          startDate: '',
          endDate: '',
          pageSize: '',
          pageNum: '',
          pauseRate: ''
        },
        dataRule: {
          gwsn: [
            { required: true, message: 'gwSN不能为空', trigger: 'blur' }
          ],
          startDate: [
            { required: true, message: 'startDate不能为空', trigger: 'blur' }
          ],
          endDate: [
            { required: true, message: 'endDate不能为空', trigger: 'blur' }
          ],
          pageSize: [
            { required: true, message: 'pageSize不能为空', trigger: 'blur' }
          ],
          pageNum: [
            { required: true, message: 'pageNum不能为空', trigger: 'blur' }
          ],
          pauseRate: [
            { required: true, message: 'pauseRate不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      sub(){
        console.log(this.dataForm)
        this.innerVisible = true;
        console.log("这是第三层")
        console.log(this.dataForm)

        this.$http({
          url: this.$http.adornUrl(`/weldingmachine/weldingmachine/analysis`),
          method: 'get',
          params: this.$http.adornParams({
            'gwsn': this.dataForm.gwsn,
            'startDate': this.dataForm.startDate,
            'endDate': this.dataForm.endDate,
            'pageSize': this.dataForm.pageSize,
            'pageNum': this.dataForm.pageNum,
            'pauseRate': this.dataForm.pauseRate
          })
        }).then(({data}) => {
          console.log("这是返回的数据")
          console.log(data)
          this.analysisList = data;
        })
      },
      init (id) {
        this.dataForm.wmname = id || 0
        this.visible = true
        console.log(this.dataForm.wmname)
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.wmname) {
            this.$http({
              url: this.$http.adornUrl(`/weldingmachineinfo/weldingmachineinfo/getGwsn`),
              method: 'get',
              params: this.$http.adornParams({
                'wmId': this.dataForm.wmname
              })
            }).then(({data}) => {
              console.log(data)
              if (data) {
                this.dataForm.gwsn = data
              }
            })
          }
        })
      }
    }
  }
</script>

<style scoped>
.input-container {
  width: 280px; /* 调整宽度值以匹配你的需求 */
}

.date-picker-container {
  width: 200px; /* 调整宽度值以匹配你的需求 */
}
</style>
